import React from 'react';
import ReactDOM from 'react-dom';
import { AppContainer } from 'react-hot-loader';
import { Provider } from 'react-redux';
import 'antd-mobile/dist/antd-mobile.css';//引入antd样式
// import 'amfe-flexible';//移动端样式
import './utils/iconfont/iconfont.css'
import './index.css';//初始化样式
import store from './redux/index';//使用rematch插件实现
import RouterMap from './router/index';
import * as serviceWorker from './serviceWorker';

//引入fundebugger
// var fundebug=require("fundebug-javascript");
// fundebug.init({
//   apikey: "3c07af78c4dea6d21c8e3b6014b6745053b26d26987848fb222719e2a9584dab"
// })

let App = () => {
  return (
    <AppContainer>
      <Provider store={store}>
        <RouterMap></RouterMap>
      </Provider>
    </AppContainer>
  )
}

//引入 fundebug
class ErrorBoundary extends React.Component<any,any> {
  constructor(props:any) {
    super(props);
    this.state = { hasError: false };
  }

  // componentDidCatch(error:any, info:any) {
  //   this.setState({ hasError: true });
  //   // 将component中的报错发送到Fundebug
  //   fundebug.notifyError(error, {
  //     metaData: {
  //       info: info
  //     }
  //   });
  // }

  render() {
    if (this.state.hasError) {
      return null
      // 也可以在出错的component处展示出错信息
      // return <h1>出错了!</h1>;
    }
    return this.props.children;
  }
}

ReactDOM.render(< ErrorBoundary >< App / ></ErrorBoundary>, document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
